package daily.aug0813;

import java.io.File;

public class Exercise_SearchFile {
    public static void main(String[] args) {
        File file01 = new File("D:\\Download\\Windows\\Theme");
        printSpecificName(file01);
    }

    private static void printSpecificName(File file) {
        File[] filesList = file.listFiles();
        //遍历filesList
        for (File f : filesList) {
            //如果遍历到的f是目录，则通过递归遍历其子目录
            if (f.isDirectory()) {
                printSpecificName(f);
            } else {
                String fileName = f.getName().toLowerCase();//获取文件名并转换为小写
                //如果文件名以.png结尾则打印出来
                if (true == fileName.endsWith(".png")) {
                    System.out.println(f);
                }
            }
        }
    }
}
